using UnityEngine;

public class FlamethowerFire : MonoBehaviour
{
	public Weapon weapon;

	public BodyPartFire fire;

	public ParticleSystem burst;

	public float damage;

	public float passChance = 0.5f;

	public float fireChance = 0.5f;

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (!collision.gameObject.TryGetComponent<BodyPart>(out var component))
		{
			return;
		}
		if ((bool)burst)
		{
			Object.Instantiate(burst, base.transform.position, Quaternion.identity);
		}
		if (component.isFireproof)
		{
			return;
		}
		component.OnHit(weapon, Vector2.right, Vector2.zero);
		if (component.onFire == null && component.damageRatio >= 1f)
		{
			if (fireChance > Random.value)
			{
				component.onFire = Object.Instantiate(fire, component.transform);
				component.onFire.damage = damage;
			}
			if (passChance < Random.value)
			{
				Object.Destroy(base.gameObject);
			}
		}
	}
}
